package cn.bs.busuo.front.content.dao.persist.repository.impl;

import cn.bs.busuo.front.content.dao.persist.mapper.UserHotelArticleDetailMapper;
import cn.bs.busuo.front.content.dao.persist.mapper.UserHotelArticleMapper;
import cn.bs.busuo.front.content.dao.persist.repository.UserHotelArticle;
import cn.bs.busuo.front.content.pojo.entity.ContentHotelArticle;
import cn.bs.busuo.front.content.pojo.entity.ContentHotelArticleDetail;
import cn.bs.busuo.front.content.pojo.vo.ContentHotelArticleByTitleVO;
import cn.bs.busuo.front.content.pojo.vo.ContentHotelArticleDetailByIdVO;
import cn.bs.busuo.front.content.pojo.vo.UserContentHotelArticleByIdVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: Feng
 * @since: 2023/12/8
 */
@Repository
public class UserHotelArticleImpl implements UserHotelArticle {

    @Autowired
    private UserHotelArticleMapper userHotelArticleMapper;

    @Autowired
    private UserHotelArticleDetailMapper userHotelArticleDetailMapper;

    //判断文章标题是否存在
    @Override
    public int contentHotelArticleByTitle(String title) {
        int title1 = userHotelArticleMapper.contentHotelArticleByTitle(title);
        return title1;
    }

    //添加文章
    @Override
    public int addNewHotelArticle(ContentHotelArticle contentHotelArticle) {
        return userHotelArticleMapper.insert(contentHotelArticle);
    }

    //根据酒店文章标题查询Id
    @Override
    public Long selectHotelArticleByTitle(String title) {
        return userHotelArticleMapper.selectHotelArticleByTitle(title);
    }

    //添加文章到详情
    @Override
    public int addNewHotelArticleDetail(ContentHotelArticleDetail contentHotelArticleDetail) {
        return userHotelArticleDetailMapper.insert(contentHotelArticleDetail);
    }

    //根据文章Id查询酒店文章
    @Override
    public ContentHotelArticle selectHotelArticleById(Long id) {
        return userHotelArticleMapper.selectHotelArticleById(id);
    }

    //用户删除文章(修改为不显示)
    @Override
    public int updateHotelArticleById(Long id) {
        return userHotelArticleMapper.updateHotelArticleById(id);
    }


    //根据酒店Id查询酒店文章
    @Override
    public List<UserContentHotelArticleByIdVO> selectHotelArticleByHotelId(Long id) {
        return userHotelArticleMapper.selectHotelArticleByHotelId(id);
    }

    //查看酒店文章详情
    @Override
    public ContentHotelArticleDetailByIdVO selectHotelArticleDetailById(Long id) {
        return userHotelArticleDetailMapper.selectHotelArticleDetailById(id);
    }

    //增加点击量
    @Override
    public void increaseClickCount(Long id) {
        userHotelArticleDetailMapper.increaseClickCount(id);
    }

    //增加点赞量
    @Override
    public int increaseUpCount(Long id) {
        return userHotelArticleMapper.increaseUpCount(id);
    }

    //增加差评
    @Override
    public int increaseDownCount(Long id) {
        return userHotelArticleMapper.increaseDownCount(id);
    }

    //增加评论量
    @Override
    public void increaseCommentCount(Long id) {
        userHotelArticleMapper.increaseCommentCount(id);
    }

    //查询自己的酒店文章
    @Override
    public List<UserContentHotelArticleByIdVO> selectUserListHotelArticle(String authorName) {
        return userHotelArticleMapper.selectUserListHotelArticle(authorName);
    }

    //查询酒店文章实体类
    @Override
    public ContentHotelArticleDetail selectHotelArticleDetail(Long id) {
        return userHotelArticleDetailMapper.selectHotelArticleDetail(id);
    }

    //修改酒店文章
    @Override
    public int updateHotelArticle(String title,String brief,String coverUrl,String keywords,Long id) {
        return userHotelArticleMapper.updateHotelArticle(title,brief,coverUrl,keywords,id);
    }

    //修改酒店文章详情
    @Override
    public int updateHotelArticleDetail(String detail,Long id) {
        return userHotelArticleDetailMapper.updateHotelArticleDetail(detail,id);
    }

    //根据文章标题查询酒店文章存入redis
    @Override
    public ContentHotelArticleByTitleVO selectHotelArticleByTitleVO(String title) {
        return userHotelArticleMapper.selectHotelArticleByTitleVO(title);
    }


}
